<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/aa.js"></script>
<link rel="stylesheet" href="front/css/common.css" type="text/css" />

</head>
<body>

	<html:form action="managementUserAction" method="post">
	<html:hidden property="backUser.userid" styleClass="userclass" styleId="backUser.userid"/> 
		<input type="hidden" name="callMethod" id="callMethod" /><br/>
		<table width="60%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			<td width="5%">帐号</td>
			<td width="15%"><html:text property="backUser.usernum" styleId="backUser.username" style="width:80%"/></td>
			<td width="5%"> 姓名</td>
			<td width="15%"><html:text property="backUser.username" styleId="backUser.username" style="width:80%"/></td>
			<td width="5%">角色</td>
			<td width="15%"><html:select property="backUser.roleid" styleId="backUser.roleid">
			<option value="-1">请选择角色</option>
				  <html:options collection="roles" labelProperty="roleName"
									property="roleID" />
							</html:select></td>
		
			<td align="center">
			<button onclick="searchUser();">搜索</button>
			</td>
			</tr>
		</table>
		
	<div id="man_zone">
			<aa:zone name="areaZone">	
 			<table width="99%" border="0" align="center" cellpadding="3"	cellspacing="1" class="table_style">
					<tr>
						<td width="15%" class="left_title_3">姓名</td>
						<td width="15%" class="left_title_3">帐号</td>
						<td width="15%" class="left_title_3">联系方式</td>
						<td width="15%" class="left_title_3">角色</td>
						<td width="15%" class="left_title_3">操作</td>
					</tr>
					<logic:iterate id="map" name="userList" indexId="index">
						<tr>
							<td > <nested:write name="map" property="username"/> </td>
							<td ><nested:write name="map" property="usernum"/></td>
							<td ><nested:write name="map" property="phone"/></td>
							<td ><nested:write name="map" property="role"/></td>
							<td ><input type="button" value="编辑" id="updateButton"  onclick="updateUser('<nested:write name="map" property="id"/>');" />
							<nested:equal value="1" property="roleid" name="map">
							<nested:equal value="0" property="ucount" name="map">
								<input type="button" id="deleteButton"  onclick="deleteUser('<nested:write name="map" property="id"/>');"  value="删除" />
							</nested:equal>
							
							<nested:notEqual value="0" property="ucount" name="map">
								<input type="button"  value="删除" disabled="disabled"/>
							</nested:notEqual>
							
							</nested:equal>
							</td>
						</tr>
					
					</logic:iterate>
					
				</table>
	<div align="right">
	<% Integer  dataTotal=new Integer(request.getAttribute("total").toString());
		Integer maxCount=new Integer(request.getAttribute("maxCount").toString());
	
	%>
				<pg:pager	
		url=""
			isOffset="true"
		    items="<%=dataTotal%>"
			maxPageItems="<%=maxCount%>"
    		maxIndexPages="10"
		    export="offset,currentPageNumber=pageNumber"
		    scope="request">
		<pg:param name="index"/>
		<pg:param name="maxPageItems"/>
		<pg:param name="maxIndexPages"/>
		
		<br>
		<pg:index>
		<jsp:include page="/common/simple.jsp" flush="true"/>
		 <html:hidden property="offset" styleId="offset" />
		 <input type="hidden" id="pager.offset" name="pager.offset" />
		</pg:index>
		</pg:pager>
			</div>

			
		</aa:zone>
	
		</div>
	</html:form>
</body>
<script type="text/javascript">
function updateUser(x1){
	$('#backUser\\.userid').val(x1);
	$('#callMethod').val('toUpdaterUser');
	document.forms[0].submit();
}


AjaxAnywhere.prototype.onAfterResponseProcessing = function () {
	$('#backUser\\.username1').val("");
	$('#backUser\\.usernum1').val("");
	$('#backUser\\.phone').val("");
	$('#backUser\\.userid').val("");
	$('#backUser\\.password').val("");
	alert("用户信息更新成功!");
	
};

function  deleteUser(x1){
	if(confirm("是否确定删除此业务员？")){
		$('#backUser\\.userid').val(x1);
		$('#pager\\.offset').val($('#offset').val());
		ajaxAnywhere.submitAJAX("deleteUser", "areaZone");
	}
	
	
}


function  searchUser(){
	$('#callMethod').val('getUser');
	$("#form").submit();
	
}

	
	ajaxAnywhere.showLoadingMessage = function() {
	}
</script>